//
//  SecetionHeaderView.m
//  Runone
//
//  Created by runone02 on 16/9/23.
//  Copyright © 2016年 runone. All rights reserved.
//

#import "SecetionHeaderView.h"
#import "UIView+Addition.h"
#import "Masonry.h"

@interface SecetionHeaderView ()

/** 文字标签 */
@property (nonatomic, strong) UILabel *label;

@end


@implementation SecetionHeaderView
+ (instancetype)sectionHeaderViewWithTableView:(UITableView *)tableView
{
    static NSString *ID = @"header";
    SecetionHeaderView *header = [tableView dequeueReusableHeaderFooterViewWithIdentifier:ID];
    if (header == nil) {
        header = [[SecetionHeaderView alloc] initWithReuseIdentifier:ID];
    }
    return header;
}

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithReuseIdentifier:reuseIdentifier]) {
//        UILabel *label = [[UILabel alloc] init];
//        label.textColor = [UIColor redColor];
//        label.width = 200;
//        label.autoresizingMask = UIViewAutoresizingFlexibleHeight;
//        [self.contentView addSubview:label];
//        self.label = label;
        [self configUI];
    }
    return self;
}

- (void)configUI {
    _label = [[UILabel alloc] init];
    [self addSubview:_label];
    __weak __typeof(self)weakSelf = self;
    [_label mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(weakSelf.mas_centerY);
        make.left.mas_equalTo(weakSelf.mas_left).with.offset(20);
    }];

}

- (void)setTitle:(NSString *)title
{
    _title = [title copy];
    
    self.label.text = title;
}




@end
